package com.web;

import com.pojo.Teacher_db;
import com.service.TeacherService_db;
import com.util.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;


import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLOutput;

@RestController
@RequestMapping("/teacher")
public class TeacherController_db {
    @Autowired
    private TeacherService_db teacherServiceDb;

    @RequestMapping("/show")
    public ResultEntity list(String name, Integer del) {
        return ResultEntity.ok(teacherServiceDb.list(name, del));
    }

    @RequestMapping("/all")
    public ResultEntity listAll() {
        return ResultEntity.ok(teacherServiceDb.listAll());
    }

    @RequestMapping("/findid")
    public ResultEntity findById(Integer id) {
        return ResultEntity.ok(teacherServiceDb.findById(id));
    }

    @RequestMapping("/add")
    public ResultEntity add(Teacher_db teacherDb) {
        return ResultEntity.ok(teacherServiceDb.add(teacherDb));
    }

    @RequestMapping("/update")
    public ResultEntity update(Teacher_db teacherDb) {
        return ResultEntity.ok(teacherServiceDb.update(teacherDb));
    }

    @RequestMapping("/updel")
    public ResultEntity updateDel(Integer tDel, Integer tId) {
        return ResultEntity.ok(teacherServiceDb.updateDel(tDel, tId));
    }

    @RequestMapping("/delete")
    public ResultEntity del(Integer tId) {
        return ResultEntity.ok(teacherServiceDb.del(tId));
    }
}
